home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / utils / bibextract / bibextract.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1992-10-29  |  4KB  |  94 lines

  1. #!/bin/sh
  2. ### ====================================================================
  3. ###  @UNIX-shell-file{
  4. ###     author          = "Nelson H. F. Beebe",
  5. ###     version         = "1.02",
  6. ###     date            = "30 October 1992",
  7. ###     time            = "19:45:16 MST",
  8. ###     filename        = "bibextract.sh",
  9. ###     address         = "Center for Scientific Computing
  10. ###                        Department of Mathematics
  11. ###                        University of Utah
  12. ###                        Salt Lake City, UT 84112
  13. ###                        USA",
  14. ###     telephone       = "+1 801 581 5254",
  15. ###     FAX             = "+1 801 581 4148",
  16. ###     checksum        = "26412 93 400 3829",
  17. ###     email           = "beebe@math.utah.edu (Internet)",
  18. ###     codetable       = "ISO/ASCII",
  19. ###     keywords        = "",
  20. ###     supported       = "yes",
  21. ###     abstract        = "",
  22. ###     docstring       = "Extract a subset of one or more bibtex
  23. ###                        files according to a regular expression
  24. ###                        pattern given on the command line, writing
  25. ###                        them on stdout.
  26. ###
  27. ###                        The pattern should avoid upper-case
  28. ###                        letters; the matching will be against a
  29. ###                        lower-cased copy of the BibTeX entry, to
  30. ###                        make letter case insignificant.
  31. ###
  32. ###                        Usage:
  33. ###                             bibextract 'keyword-pat' 'regexp-pat' \
  34. ###                                bibtex-file(s) >new-bibtex-file
  35. ###
  36. ###                        If the keyword-pat pattern is empty,
  37. ###                        matching occurs against the entire
  38. ###                        bibliographic entry.
  39. ###
  40. ###                        Here are some examples:
  41. ###
  42. ###                        Extract all entries mentioning chaos in any field:
  43. ###
  44. ###                             bibextract "" "chaos" file(s) >new-bibtex-file
  45. ###
  46. ###                        Extract entries with names Brown or Smith
  47. ###                        occurring in either of the author or editor
  48. ###                        fields:
  49. ###
  50. ###                             bibextract "author|editor" "brown|smith" \
  51. ###                                 file(s) >new-bibtex-file
  52. ###
  53. ###                        Extract entries for titles containing the
  54. ###                        letter z anywhere after a vowel; note that
  55. ###                        single quotes are necessary to provide the
  56. ###                        necessary protection from shell expansion:
  57. ###
  58. ###                             bibextract "title" '[aeiou].*z' file(s) \
  59. ###                                 >new-bibtex-file
  60. ###
  61. ###                        The checksum field above contains a CRC-16
  62. ###                        checksum as the first value, followed by the
  63. ###                        equivalent of the standard UNIX wc (word
  64. ###                        count) utility output of lines, words, and
  65. ###                        characters.  This is produced by Robert
  66. ###                        Solovay's checksum utility.",
  67. ###  }
  68. ### ====================================================================
  69.  
  70. ### Edit history (reverse chronological order):
  71. ### [30-Oct-1992]    1.02    Fix typographical error.
  72. ### [21-Oct-1992]       1.01    Update for public distribution.
  73. ### [08-May-1989]       1.00    Original version.
  74.  
  75. TMPFILE=/tmp/bibtextract.$$
  76. LIBDIR=@LIBDIR@
  77.  
  78. trap '/bin/rm -f ${TMPFILE}' 2 1
  79.  
  80. # Make a new awk program with the patterns built in.
  81. /bin/sed    -e "sKEYWORD$1"\
  82.             -e "sPATTERN$2"\
  83.             <@LIBDIR@/bibextract.awk >${TMPFILE}
  84.  
  85. # Discard first 2 arguments (keyword-pat and regexp-pat)
  86. shift
  87. shift
  88.  
  89. # Extract the bibliography subset
  90. nawk -f ${TMPFILE} $*
  91.  
  92. # discard our temporary file
  93. /bin/rm -f ${TMPFILE}
  94.